// extend UIAction if this action should be UI Kismet Action instead of a Level Kismet Action
class PSKismetGFXSubtitles extends SequenceAction;

/*var(CanvasText) string Text;
var(CanvasText) float TimeTextVisible;*/

struct SubtitleSeq
{
	var() bool isDidrik;
	var() string Text;
	var() float Time;
};

var(Subtitulos) bool IsTopSubtitle;
var(Subtitulos) array<SubtitleSeq> SubtitulosES;
var(Subtitulos) array<SubtitleSeq> SubtitulosEN;

var PSPlayerController pc;

/** Player that should take credit for the health change (Controller or Pawn) 
var Actor Instigator;
*/

event Activated()
{
	local array<PSTextSequence> subSqES,subSqEN;
	local int ind;

	pc = none;

	if (Targets.length == 0)
	{
		`Log("WARNING: No Target for Subtitle DisplayText");
	}
	else
	{
		if(Targets[0].IsA('PSPlayerController'))
		{
			pc = PSPlayerController(Targets[0]);
		}
		else if(Targets[0].IsA('PSPawnDidrik'))
		{
			pc = PSPlayerController(PSPawnDidrik(Targets[0]).Controller);
		}

		if(pc==none) return;
		
		if (InputLinks[0].bHasImpulse)
		{
			if(SubtitulosES.Length>0)
			{
				subSqES.Add(SubtitulosES.Length);

				for(ind=0;ind<SubtitulosES.Length;ind++)
				{
					subSqES[ind] = new class'PSTextSequence';
					subSqES[ind].isDidrik = SubtitulosES[ind].isDidrik;
					subSqES[ind].Text = SubtitulosES[ind].Text;
					subSqES[ind].Time = SubtitulosES[ind].Time;
				}
			}

			if(SubtitulosEN.Length>0)
			{
				subSqEN.Add(SubtitulosEN.Length);

				for(ind=0;ind<SubtitulosEN.Length;ind++)
				{
					subSqEN[ind] = new class'PSTextSequence';
					subSqEN[ind].isDidrik =SubtitulosEN[ind].isDidrik;
					subSqEN[ind].Text =SubtitulosEN[ind].Text;
					subSqEN[ind].Time = SubtitulosEN[ind].Time;
				}
			}

			if(IsTopSubtitle)
			{
				pc.PlaySubtitlesTop(subSqES,subSqEN);
			}
			else
			{
				pc.PlaySubtitles(subSqES,subSqEN);
			}
		}
		else
		{
			if(IsTopSubtitle)   pc.PSStopSubtitleTop();
			else                pc.PSStopSubtitle();
			
		}
	}
}

defaultproperties
{
	ObjName="PSKismetGFXSubtitles"
	ObjCategory="PS Actions"
	
	InputLinks(0)=(LinkDesc="Start")
	InputLInks(1)=(LinkDesc="Stop")

	IsTopSubtitle = false
}